/**
 * 
 */
package com.yidu.erp.service.department;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.yidu.common.Tools;
import com.yidu.erp.dao.BeyondDepartmentMapper;
import com.yidu.erp.model.BeyondDepartment;

/**
 * 部门Service实现类
 * @author zengren
 * @date 2017年11月24日
 * @version 1.0
 */
@Service
public class DepartmentServiceImpl implements DepartmentService{
	
	@Resource
	private BeyondDepartmentMapper beyondDepartmentMapper;

	@Override
	public int addOrUpdate(BeyondDepartment department) {
		int rows = 0;
		if(Tools.isEmpty(department.getDepartId())){
			rows = beyondDepartmentMapper.insertSelective(department);
		}else{
			rows = beyondDepartmentMapper.updateByPrimaryKeySelective(department);
		}
		return rows;
	}

	@Override
	public int delete(String departId) {
		// TODO Auto-generated method stub
		return beyondDepartmentMapper.delete(departId);
	}

	@Override
	public Map<String, Object> showList(Map<String, Object> param) {
		// TODO Auto-generated method stub
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("data", beyondDepartmentMapper.showList(param));
		map.put("count", beyondDepartmentMapper.countRows(param));
		map.put("code", 0);
		map.put("msg", 0);
		return map;
	}

	@Override
	public BeyondDepartment findById(String departId) {
		// TODO Auto-generated method stub
		return beyondDepartmentMapper.selectByPrimaryKey(departId);
	}

	@Override
	public String getIdByName(String deparId) {
		// TODO Auto-generated method stub
		return beyondDepartmentMapper.getIdByName(deparId);
	}
	
	
	
}
